﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="open_Trash.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Gallery.open_Trash" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <%
        var get_trash = new TblLibraryController().FetchAll().Where(x => x.LibraryTrash == true && x.LibraryDelete == false);
        var get_admin = new TblManagerController().FetchAll().Where(x=>x.ManagerId==int.Parse(Session["admin_id"].ToString())).Single();
        bool check = false;
        check = (bool)get_admin.Captain;
        if (get_trash.ToList().Count == 0)
        {
    %>
    <div class="gal-folder-empty w3-row">
        <div class="w3-col l1 w3-center w3-jumbo">
            <i class="fa fa-trash"></i>
        </div>
        <div class="w3-col l11 w3-text-grey w3-padding">
            <p class="w3-padding-top">
                <span class="w3-large">Không có tập tin hoặc thư mục nào trong <b>Thùng rác</b>.</span><br />
                Chuyển những tập tin hoặc thư mục mà bạn không cần dùng tới vào <b>Thùng rác</b>.<br />
                Bạn có thể phục hồi hoặc xóa vĩnh viễn những tập tin hoặc thư mục đó tùy ý.
            </p>
        </div>
    </div>
    <%}
        else
        { %>
    <table class="gal-table-head w3-table w3-bordered">
        <thead>
            <tr>
                <td class="gal-table-name gal-table-sort-name"><i class="fa fa-chevron-down"></i>Tên</td>
                <td class="gal-table-date gal-table-sort-date">Ngày tạo</td>
                <td class="gal-table-modified gal-table-sort-modified">Ngày Xóa</td>
                <td class="gal-table-options">Tùy chọn</td>
            </tr>
        </thead>
    </table>
    <table class="gal-table-data w3-table w3-white">
        <%
            var get_folder = new TblLibraryController().FetchAll().Where(x => x.LibraryType == 0 && x.LibraryTrash == true && x.LibraryDelete == false);
            foreach (TblLibrary folder in get_folder)
            {
                var get_uploader = new TblManagerController().FetchAll().Where(x => x.ManagerId == folder.LibraryUploader).Single();
                var get_editor = new TblManagerController().FetchAll().Where(x => x.ManagerId == folder.LibraryEditor).Single();
                string upload_date = "", edit_date = "";
                DateTime date = DateTime.Parse(folder.LibraryUploadDate.ToString());
                upload_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
                date = DateTime.Parse(folder.LibraryEditDate.ToString());
                edit_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
        %>
        <tr id="item<%=folder.LibraryId %>">
            <td class="gal-table-name"><i class="fa fa-folder"></i><%=folder.LibraryName %></td>
            <td class="gal-table-date"><span title="<%=get_uploader.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=date %></span></td>
            <td class="gal-table-modified"><span title="<%=get_editor.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=edit_date %></span></td>
            <td class="gal-table-options">
                <%--<i title="Đã xóa ngày 14/10/2016 15:59 bởi Phan Bá Tài" data-toggle="tooltip" data-placement="bottom" class="fa fa-info w3-hover-text-teal"></i>--%>
                <i onclick="gal_restore(<%=folder.LibraryId %>)" title="Khôi phục" data-toggle="tooltip" data-placement="bottom" class="fa fa-recycle w3-hover-text-teal"></i>
                <%if(check==true){ %>
                <i onclick="gal_detroy(<%=folder.LibraryId %>)" title="Xóa vĩnh viễn" data-toggle="tooltip" data-placement="bottom" class="fa fa-trash w3-hover-text-teal"></i>
                <%} %>
            </td>
        </tr>
        <%}
            var get_img = new TblLibraryController().FetchAll().Where(x => x.LibraryTrash == true && x.LibraryDelete == false && x.LibraryType == 1);
            foreach (TblLibrary img in get_img)
            {
                var get_uploader = new TblManagerController().FetchAll().Where(x => x.ManagerId == img.LibraryUploader).Single();
                var get_editor = new TblManagerController().FetchAll().Where(x => x.ManagerId == img.LibraryEditor).Single();
                string upload_date = "", edit_date = "";
                DateTime date = DateTime.Parse(img.LibraryUploadDate.ToString());
                upload_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
                date = DateTime.Parse(img.LibraryEditDate.ToString());
                edit_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
                   
        %>
        <tr id="item<%=img.LibraryId %>">
            <td class="gal-table-name"><img src="../Content/testdata/picture/<%=img.LibraryLink %>" alt="[img not found!]" onclick="gal_view_img(this,'<%=img.LibraryName %>')" title="Xem ảnh" data-toggle="tooltip" data-placement="bottom" /></td>
            <td class="gal-table-date"><span title="<%=get_uploader.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=date %></span></td>
            <td class="gal-table-modified"><span title="<%=get_editor.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=edit_date %></span></td>
            <td class="gal-table-options">
                <%--<i title="Đã xóa ngày 14/10/2016 15:59 bởi Phan Bá Tài" data-toggle="tooltip" data-placement="bottom" class="fa fa-info w3-hover-text-teal"></i>--%>
                <i onclick="gal_restore(<%=img.LibraryId %>)" title="Khôi phục" data-toggle="tooltip" data-placement="bottom" class="fa fa-recycle w3-hover-text-teal"></i>
                <%if(check==true){ %>
                <i onclick="gal_detroy(<%=img.LibraryId %>)" title="Xóa vĩnh viễn" data-toggle="tooltip" data-placement="bottom" class="fa fa-trash w3-hover-text-teal"></i>
                <%} %>
            </td>
        </tr>
        <%}
            var get_snd = new TblLibraryController().FetchAll().Where(x => x.LibraryTrash == true && x.LibraryDelete == false && x.LibraryType == 2);
            foreach (TblLibrary snd in get_snd)
            {
                var get_uploader = new TblManagerController().FetchAll().Where(x => x.ManagerId == snd.LibraryUploader).Single();
                var get_editor = new TblManagerController().FetchAll().Where(x => x.ManagerId == snd.LibraryEditor).Single();
                string upload_date = "", edit_date = "";
                DateTime date = DateTime.Parse(snd.LibraryUploadDate.ToString());
                upload_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
                date = DateTime.Parse(snd.LibraryEditDate.ToString());
                edit_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
            
        %>
        <tr id="item<%=snd.LibraryId %>">
            <td class="gal-table-name"><i onclick="gal_play_audio(event,'<%=snd.LibraryLink %>')" title="Phát âm thanh" data-toggle="tooltip" data-placement="bottom" class="gal-play-audio-btn fa fa-volume-up w3-hover-text-teal"></i><i onclick="gal_stop_audio(event)" title="Dừng" data-toggle="tooltip" data-placement="bottom" class="gal-stop-audio-btn fa fa-pause w3-hover-text-teal"></i><span class="item_name"><%=snd.LibraryName %></span></td>
            <td class="gal-table-date"><span title="<%=get_uploader.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=date %></span></td>
            <td class="gal-table-modified"><span title="<%=get_editor.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=edit_date %></span></td>
            <td class="gal-table-options">
                <i onclick="gal_restore(<%=snd.LibraryId %>)" title="Khôi phục" data-toggle="tooltip" data-placement="bottom" class="fa fa-recycle w3-hover-text-teal"></i>
                <%if(check==true){ %>
                <i onclick="gal_detroy(<%=snd.LibraryId %>)" title="Xóa vĩnh viễn" data-toggle="tooltip" data-placement="bottom" class="fa fa-trash w3-hover-text-teal"></i>
                <%} %>
            </td>
        </tr>
        <%}
            var get_vid = new TblLibraryController().FetchAll().Where(x => x.LibraryTrash == true && x.LibraryDelete == false && x.LibraryType == 3);
            foreach (TblLibrary vid in get_vid)
              {
                  var get_uploader = new TblManagerController().FetchAll().Where(x => x.ManagerId == vid.LibraryUploader).Single();
                  var get_editor = new TblManagerController().FetchAll().Where(x => x.ManagerId == vid.LibraryEditor).Single();
                  string upload_date = "", edit_date = "";
                  DateTime date = DateTime.Parse(vid.LibraryUploadDate.ToString());
                  upload_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
                  date = DateTime.Parse(vid.LibraryEditDate.ToString());
                  edit_date = date.Day + "/" + date.Month + "/" + date.Year + " " + date.Hour + ":" + date.Minute;
          %>
        <tr id="item<%=vid.LibraryId %>">
            <td class="gal-table-name"><span class="gal-video-link" hidden="hidden"><%=vid.LibraryLink %></span><i onclick="gal_watch_video(this)" title="Xem video" data-toggle="tooltip" data-placement="bottom" class="fa fa-youtube-play w3-hover-text-teal"></i><span class="gal-video-name"><span class="item_name"><%=vid.LibraryName %></span></span></td>
            <td class="gal-table-date"><span title="<%=get_uploader.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=date %></span></td>
            <td class="gal-table-modified"><span title="<%=get_editor.FullName %>" data-toggle="tooltip" data-placement="bottom"><%=edit_date %></span></td>
            <td class="gal-table-options">
                <%--<i title="Đã xóa ngày 14/10/2016 15:59 bởi Phan Bá Tài" data-toggle="tooltip" data-placement="bottom" class="fa fa-info w3-hover-text-teal"></i>--%>
                <i onclick="gal_restore(<%=vid.LibraryId %>)" title="Khôi phục" data-toggle="tooltip" data-placement="bottom" class="fa fa-recycle w3-hover-text-teal"></i>
                <%if(check==true){ %>
                <i onclick="gal_detroy(<%=vid.LibraryId %>)" title="Xóa vĩnh viễn" data-toggle="tooltip" data-placement="bottom" class="fa fa-trash w3-hover-text-teal"></i>
                <%} %>
            </td>
        </tr>
        <%} %>
    </table>
    <%} %>
</body>
</html>
